---
title: Update a task
summary: Persist changes to an existing task via the pk82036_task.task_update stored procedure with optimistic concurrency.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Business.Tasks
reference_type: embedded
operation_id: OP-3
trigger: Application calls Save() on a modified task
---

# Update a task

This operation persists changes to an existing task row via `pk82036_task.task_update`, enforcing optimistic concurrency using `UPDATE_SEQ_NUM`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-3 |
| **Trigger** | Application calls `Save()` on a modified task |
| **Inputs** | Modified `clsTask` instance |
| **Outputs** | Updated `TASK` row |
| **Primary components** | `clsTask.BeforeUpdate`, `clsTask.AfterUpdate` |
| **Entry point** | `SAIF.Business.Tasks/clsTask.vb` |

## Steps

1. The same common business rules as insert are re-evaluated before update ([BR-001](../business-rules.md#br-001-a-task-must-have-a-task-category-code)–[BR-008](../business-rules.md#br-008-automatic-due-date-shifting-must-be-surfaced-as-a-warning)).
   - On failure: save is blocked unless overridden ([BR-026](../business-rules.md#br-026-descendant-task-types-may-override-common-rule-outcomes)).
2. Set `UpdateDate = Now` and `UpdateUser = DPI.UserID`.
3. Build a `NonQuery` `StoredProcedure` request on `pk82036_task.task_update` with the mutable columns (task user/MailID, action/category/priority codes, date, text, policy number, claim ID, image sequence number, task security), the six context values, the key values `TaskSeqNum` + `UpdateSeqNum` (optimistic concurrency token, [BR-013](../business-rules.md#br-013-optimistic-concurrency-via-update-sequence-number)), and `RowsAffected` as `ReturnValue` ([SQL-013](../sql/SQL-013-update-task.md), [TASK](../database-tables.md#task)).
   - Note: `TaskSourceCode` is **not** a parameter of the update call — the source system is immutable after insert*.
   > **Origin**: The `task_update` procedure body resides in the Oracle database and was not retrieved in this analysis pass.**
4. Framework executes the request against the DPI.
5. After execution:
   - `RowsAffected <> 1` → `AddErrorMessage("UpdateError", clsConstants.Messages.DBContentionError)` ([BR-011](../business-rules.md#br-011-task-update-must-affect-exactly-one-row), [BR-013](../business-rules.md#br-013-optimistic-concurrency-via-update-sequence-number)).
   - Otherwise: remove the message, increment `m_UpdateSeqNum`, call `MarkOld()`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Save called on modified task]) --> D{Business rules pass?}
	D -->|No| ErrEnd([Save blocked])
	D -->|Yes| S1["BeforeUpdate builds<br>task_update request with<br>UpdateSeqNum"]
	S1 --> S2[Framework executes request]
	S2 --> D2{RowsAffected = 1?}
	D2 -->|No| ErrEnd2(["UpdateError:<br>DBContentionError"])
	D2 -->|Yes| S3["Increment UpdateSeqNum,<br>MarkOld"]
	S3 --> EndOk([Task persisted])
```

## Failure and edge-case behavior

- A stale `UpdateSeqNum` (another process updated the row first) yields `RowsAffected = 0`, surfaced as a `DBContentionError` rather than an exception ([BR-011](../business-rules.md#br-011-task-update-must-affect-exactly-one-row), [BR-013](../business-rules.md#br-013-optimistic-concurrency-via-update-sequence-number)).
- Source system code cannot be changed once a task is created*.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Business.Tasks/clsTask.vb
